<?php
/*
 * Created on Jul 3, 2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<?php

class Model_sys extends Model {
	var $_tbl_name;

	function __construct() {
		// Call the Model constructor
		parent :: Model();
		$this->_tbl_name = "tbl_sys";
	}
	function findByUP($user_name, $pass){
		$sql= "SELECT * FROM ".$this->_tbl_name." WHERE name='".$user_name."' and pass='".$pass."'";
		$query = $this->db->query($sql);
		if ($query->num_rows() > 0) {
			return $query->first_row('array');
		}
		return null;
	}
	function find($id){
		$this->db->where('id',$id);
		$query = $this->db->get($this->_tbl_name);
		
		return $query->first_row('array');
	}
	
	function fetch_all(){
		$query = $this->db->get($this->_tbl_name);
		return $query->result_array();
	}
	
	function insert($data){
		$this->db->insert($this->_tbl_name,$data);
	}
	function update($data,$id){		
		$this->db->update($this->_tbl_name,$data,array('id'=>$id));
	}
	function delete($id){
		$this->db->delete($this->_tbl_name,array('id'=>$id));
	}
}
?>